package io.github.cubelitblade.dao;

import io.github.cubelitblade.models.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao {
    @Insert("INSERT INTO users(name, gender, age) VALUES(#{name}, #{gender}, #{age})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(User user);

    @Delete("DELETE FROM users WHERE id=#{id}")
    int delete(long id);

    @Select("SELECT * FROM users WHERE id=#{id}")
    User selectById(long id);

    @Update("UPDATE users SET name=#{name}, gender=#{gender}, age=#{age} WHERE id=#{id}")
    int update(User user);

    @Select("SELECT * FROM users")
    List<User> selectAll();
}
